home *** CD-ROM | disk | FTP | other *** search
/ Mac Magazin/MacEasy 24 / Mac Magazin and MacEasy Magazine CD - Issue 24.iso / Wissenschaft & Technik / Survival 6.1.3. Pack / Survival 6.1.3.FPU / Survival 6.1.3.FPU.rsrc / TEXT_128_'Macros'.txt < prev    next >
Text File  |  1994-06-29  |  20KB  |  449 lines

  1.                  ‚Ä¢‚Ä¢ DESCRIPTION OF MACRO COMMANDS ‚Ä¢‚Ä¢
  2.      
  3.     This commands allow the user to perform fully automated survival analysis and
  4.     to select,transform or recode the variables in the active data array. See the
  5.      examples in the Survival Macros file to learn how to use this commands. You
  6.      may use small letters, capital letters or both to define these commands. It also
  7.     allows the computing of descriptive statistics for the data array in memory and
  8.     the exact P value for normal, chi-square, Student and F probability distributions.
  9.  
  10.     ‚Ä¢BACKCOLOR ( 'white', 'black' ) sets the background color for graphical plots.
  11.     You must put  one of the arguments in the list above;otherwise you'll get an error
  12.    message. The Type is STRING. 
  13.  
  14.     ‚Ä¢BEEP; beeps for one second.
  15.  
  16.   ‚Ä¢CHIPROB(chi,df); computes the exact  P value of ChiSquare distribution 'chi' 
  17.      with 'df' degrees of freedom.
  18.  
  19.    ‚Ä¢CATEGORIES(var1,var2,..option). Indentifies the categorical variables in the
  20.    data array included in the model that have to be transformed into DEVIATION
  21.     (option = 0) or INDICATOR (option = 1) variables.
  22.  
  23.    ‚Ä¢CHITEST(var1,var2); computes a Chi-Square Test for categories in the 'var1'
  24.     column of the data array by the categories in the 'var2' column of the data array.
  25.     Results are presented in a contingency table where the rows are the max number
  26.     of categories in 'var1' and the columns the max number of categories in 'var2'
  27.     The maximum number of categories (n) is seven and the categories should be
  28.     enumerated from 1 ......to  n categories.
  29.  
  30.     ‚Ä¢CLEAR; clears the active output window. This option is not available with the
  31.       Macro Command submenu if you use System 6.xx
  32.  
  33.     ‚Ä¢COMPUTE. This command is used to recode or transform variables in a speedy
  34.     fashion. It has the following syntax's:
  35.  
  36.             COMPUTE
  37.                   statement ;
  38.                   statement ;
  39.                 etc.    ;
  40.             END;
  41.  
  42.     See the examples in the Survival Macros  file to learn how to use this command.
  43.  
  44.     ‚Ä¢COUNTIF( Boolean expresion  )  count the number of cases in the active data
  45.     array that match the conditions specified in the Boolean  argument. Use the
  46.     rDATA[ ] token to access the variables in the active data array. The result of
  47.     the count command is displayed on the active Output Window.
  48.       Example:
  49.  
  50.             COUNTIF((rData[1] > 50) and (rData[2] =3));
  51.  
  52.     ‚Ä¢COVARIATES (number, number ....) set covariate pattern values for the 
  53.     current survival test. The Type is REAL.
  54.  
  55.     ‚Ä¢CREATE ( filename, Var, Var, Var ... ) . Creates a  new File filename 
  56.     with the variables  specified in the argument list. 
  57.  
  58.         Example:  CREATE ('HD80:Data:MyNewFile', 1,2,3,7,8);
  59.     
  60.     ‚Ä¢ESTIMATE; starts estimation of Mle's and survival functions. It has no
  61.     arguments.
  62.     You must always specify the column number of the status variable and time
  63.     variable with  SETSTATUS(n) and SETTIME(n)  before issuing this command; 
  64.     otherwise you'll get an error message.
  65.     
  66.     ‚Ä¢EXIT; terminates macro execution.
  67.  
  68.   ‚Ä¢FIXDATA; makes permanente the changes in the data array. You need to reload
  69.     your data file if you want your original data back.
  70.  
  71.  
  72.     ‚Ä¢FORMAT(DataLength,DataDecimals) sets the data length and the number of
  73.    figures after the decimal point for numerical output.
  74.  
  75.   ‚Ä¢FPROB(F,df1,df2); computes the exact  P value of F distribution F with df1
  76.    and df2 degrees of freedom.
  77.  
  78.     ‚Ä¢FUNCTION . This command has the following syntax's:
  79.  
  80.             FUNCTION
  81.                   statement ;
  82.                   statement ;
  83.                 etc.    ;
  84.             END;
  85.  
  86.     It must be only used to compute the value of the variables at each failure point
  87.   when you chose a Time Dependent Analysis by pressing the Option Key while
  88.   selecting the variables to be included in the model or when using the macro
  89.   command VARCODE(number, number) within a Macro. See example in the Macro
  90.   Time1 macro file to learn how to use this command.
  91.  
  92.     ‚Ä¢GET ( Rows, Columns, nVars ); gets the number of rows, number of columns and
  93.     the number of selected vars of the active data array. The Type is INTEGER;
  94.     
  95.     ‚Ä¢GETDATA( 'filename'  ) loads data from a binary file or a tab delimited text file.
  96.     If the data file is in a different folder or volume you must specify the full path to
  97.     access the file. If not, a dialog box  is shown. The TYPE is STRING.
  98.  
  99.     ‚Ä¢GROUPLABEL(Val:'string'; Val: 'string' ....) puts labels to the groups for both
  100.      numerical and graphical output. Val is the value of the categorial variable that
  101.    identify the different groups in stratified analysis.
  102.  
  103.  ‚Ä¢INTPLOT(option); actives the plot of the Confidence Intervals for the current
  104.      survival function. It must be used after the ESTIMATE command. option is 1
  105.      for 95% CI and 2 for 99% CI.
  106.  
  107.     ‚Ä¢LIST ( length, decimals ); Updates the output window and list the entire data
  108.     array with the format given by the two arguments. The Type is INTEGER.
  109.  
  110.   ‚Ä¢LOGPLOT; activates the plot of Log -(Log) of Survival function, which is used for
  111.      testing the proportionality assumption.It must be used after the ESTIMATE
  112.      macro command.
  113.  
  114.     ‚Ä¢MACRO; command needed to identify a Macro procedure. The text in quotes after
  115.     the word MACRO is added as a new command in the MACRO Menu.
  116.  
  117.         Example:   Macro 'My Macro';
  118.     
  119.     ‚Ä¢MAKEBINS ( VarIn,VarOut,Option,Bin1,Bin2,Bin3 ...... BinMax  ). This command
  120.      recodes a numerical variable into categories. VarIn  is the source column number.
  121.    VarOut specifies the column number where to put the newly recoded variable.
  122.    If VarOut  equals to VarIn , all data in the source column will be overwritten.
  123.    Option  is a Boolean variable; when is set to true the first category of the new
  124.    coded variable corresponds to those values of the numerical variables that  are
  125.    less than the value specified in Bin1 and the last category to those values that
  126.    are equal  or greater than the  value given in BinMax. 
  127.    THE MAX NUMBER OF BINS THE COMMAND CAN CREATE  IS 30. 
  128.         Example 1:  MAKEBINS (3,3,true, 40,50,60,70) will recode the variable in
  129.     column 3 and put the result in the same column as follows:
  130.  
  131.             Value                   Category N¬∫
  132.             < 40                            1
  133.             40 - 49                             2
  134.             50 - 59                                 3
  135.             60 - 69                                 4
  136.           70 =>                                     5
  137.     Example 2: MAKEBINS(3,4,false,40,50,60,70) will codify the variable in column
  138.   3 and put the result in column 4 as follows:
  139.             Value               Category N¬∫
  140.             40 - 49                                1
  141.             50 - 59                                2
  142.             60 - 69                                3
  143.  
  144.   This second option should cover the whole value range of the variables. If not, you
  145.   may get a combination of both categorical and numerical variables in the same
  146.   column. If not, you're warned with a message.        
  147.     
  148.     ‚Ä¢NEWVARS ( number, default ) . This command appends to the right of the active
  149.     data array  new number  columns with the default value. It is used to create
  150.     dummy variables to store, for example, the transformed values of other
  151.     variables.  Example  NEWVARS( 2, 0);
  152.  
  153.   ‚Ä¢NORMPROB(Z); computes the exact  P value of Normal distribution 'Z'
  154.  
  155.     ‚Ä¢OMITIF(Boolean argument) ; excludes from the active data array the cases that
  156.     meet the conditions specified in the Boolean  argument. Use the rDATA[ ] token to
  157.     access the variables in the active data array.
  158.  
  159.    ‚Ä¢PARAMETRIC('ModelType', option1, option2, option3, option4, sigma);
  160.  
  161.     "Model Type" is the the type of Parametric Model:
  162.           -Set 'ModelType' to 'exponential' to fit data to a exponential model
  163.             -Set 'ModelType' to 'weibull' to fit data to a two Parameter Weibull model
  164.           -Set 'ModelType' to 'lognormal' to fit data to a Log-Normall model
  165.  
  166.       'option1', 'option2' and 'option3' are boolean expressions:
  167.           -Set 'option1' to true if you want to use a constant term. This option should
  168.           always be true if you include covariates in the model
  169.           -Set 'option2' to true to center the covariates values around their mean value
  170.             -Set 'option3' to true if you want the iterations to be printed in the output
  171.            window
  172.         -Set 'option4' to true if you want the Cumulative Distribution insted of the
  173.           Survival Function to be plotted for the Survival Function adjusted for the
  174.           effect of the covariables in the model.
  175.  
  176.        'sigma' is the initial value for estimation of the model's sigma term. Should be
  177.         set to 1 unless you have convergence problems
  178.  
  179.       Example:  parametric('weibull',true,false,false,true,1);
  180.  
  181.  
  182.  
  183.     ‚Ä¢RECODE ( Var,OldValue,NewValue, [Default Value]  ). This comand easily recodes
  184.    the OldValue  for the variable number Var with NewValue. Default Value  is
  185.    optional; if you specify  it,  the variables with values different to OldValue take
  186.    its value. Is the same as if you used the following Pascal statement  within
  187.    a standard procedure : 
  188.  
  189.         'If  OldValue  then NewValue  else DefaultValue'.
  190.  
  191.       You may use either the name of a previously defined variable with the column
  192.      number you want to transform, the column number itself or a matrix definition
  193.      (rVar[column number] or rData[column number]).
  194.       Example: The following commands will render the same result:
  195.  
  196.            RECODE(1:1:2;5:1:2:-1);
  197.              grade:= 3; stage:= 5;
  198.             RECODE(grade:1:2;stage:1:2:-1);
  199.             Recode(rData[3]:1:2;rData[5]:1:2:-1);
  200.  
  201.       You may use colons or commas as delimiter of the arguments. Use a semicolon as
  202.     delimiter when you  recode different variables with a single command.
  203.  
  204.     ‚Ä¢RESET; this command set different flags and constants needed for the survival
  205.       algorithm. It has no arguments and should be the first command in a procedure
  206.     that uses macro commands, before setting the parameters for the test in course.
  207.  
  208.   ‚Ä¢RESPLOT; activates the plot of the Cumulative Function for Residuals, which is
  209.      used to Test the goodness of fit of data to model. It must also be used after the
  210.      ESTIMATE macro command.
  211.  
  212.     ‚Ä¢REVERT; restores the values in the active data array to the values contained in
  213.     the last loaded data file. It has no arguments. You'll appreciate this macro when
  214.     you need to transform, recode or select your original data for a given task.
  215.  
  216.   ‚Ä¢RUNMACRO(number); excutes the macro located in the item number in the
  217.     Macro Menu. Useful for linking different macros in complex automated survival
  218.     analysis. Read carefully the macros in the 'Survival Macros' to learn how to
  219.     use these command.
  220.  
  221.     ‚Ä¢SAVEDATA('Filename',['text','binary' ]) saves data in the active data array 
  222.     as a Tab delimited text file (text) or as a binary application file (binary). You
  223.     must  put  one of the string arguments in the list above, otherwise you'll get an
  224.     error message. If you omit the Filename a standard file dialog box is presented. 
  225.  
  226.     ‚Ä¢SAVEMODEL; Saves the parameters of the current estimated model for further
  227.     use with the Survival Chart option of the Survival Menu. It has no arguments.
  228.  
  229.   ‚Ä¢SAVEPICT('name') saves the picture displayed in the active plot window to
  230.     disk in the same folder than the application. This command should be used after
  231.     the SURVPLOT, INTPLOT, LOGPLOT and RESPLOT commands, if you pretend to
  232.     make  different survival analysis with a single macro and want to save the
  233.     graphical output.This macro also closes the active Plot window after saving to
  234.     the disk. 
  235.     If you use an empty string as the name argument, until you start a new analysis
  236.     the graphic plots ar saved as Kaplan-Meier.PICTn, Model.PICTn, LogLog.PICTn,
  237.     Intervals.PICTn and Residuals.PICTn, where 'n' is automatically increased for
  238.     each saved file of the same graphic type.
  239.     Use a Path if you want the pictures saved in a different folder
  240.     This option is not available with the Macro Command submenu
  241.  
  242.     ‚Ä¢SAVETEST('filename'). Saves in the file filename  the numerical results of the 
  243.       current Test in the active Output Window. You should use this macro when the
  244.     output window exceeds 37000 characters, the maximum allowed for text files.
  245.     
  246.     ‚Ä¢SELECTIF ( Boolean argument  ). Selects from the active data array the cases
  247.     that meet the conditions specified in the Boolean  argument. As with the OMITIF
  248.     command, use the rDATA[i] token to access the variables in the active data
  249.     array.
  250.  
  251.     ‚Ä¢SELECTVAR(number, number, ..); this command selects the variables to be
  252.     included in the regression model. Number specifies the column number of the
  253.     data file where variables are located. The Type is INTEGER.
  254.  
  255.     ‚Ä¢SET( Rows,Columns,nVars ); sets the new number of Rows (cases), Columns
  256.     (variables) and the number of selected vars (nVars), if any,  for the active data
  257.     array.The Type is INTEGER.
  258.  
  259.     ‚Ä¢SETCUTPOINT(number, varnumber). Sets cut point value number.
  260.      Varnumber is the column number of the variable. The Type is REAL for the
  261.      first argument and NTEGER for the second argument.
  262.  
  263.     ‚Ä¢SETFAILCODE (number). Sets the code identifying the terminal event. The Type
  264.     is INTEGER
  265.  
  266.     ‚Ä¢SETITER (number) sets number of max iterations for the Newton-Raphson
  267.      algorithm. The Type is INTEGER.
  268.  
  269.  ‚Ä¢SORTBY(column1,column2).Sorts data array in ascending order by column1
  270.     and column2. If you put a zero for the value in column2 the data array is only
  271.      sorted by the ascending order of values in column1.
  272.  
  273.   ‚Ä¢SURVPLOT. Activates the plot of both Kaplan-Meier and Model Survival
  274.      functions.
  275.      It must be used before the ESTIMATE macro command. This macro substitutes
  276.      the GRAPHPLOT('true','false') command of previous versions.
  277.  
  278.     ‚Ä¢VARLABEL(Var:'string'; Var: 'string' ....) puts labels to the selected variables.
  279.     Var  is the column number of the variable in the active DATA ARRAY.
  280.  
  281.     ‚Ä¢SETOUTPUT('all', 'none', 'basal', model'). Selects numerical output to be shown
  282.     on the active output window. You must put  one of the arguments in the list above;
  283.     otherwise you'll get an error message. The Type is STRING.
  284.  
  285.     ‚Ä¢SETPRECISION( number). Sets the  level of precision for estimation of the
  286.     coefficients of the regression model. The Type is REAL.
  287.  
  288.     ‚Ä¢SETSTATUS(number); sets the column number where the status variable is
  289.    locate in the active data array. The Type is INTEGER.  
  290.  
  291.     ‚Ä¢SETSTRATA (number, stratavar) .Sets the number of strata and the column
  292.     number of the strata variable stratavar to perform  stratified analysis.
  293.     The Type is INTEGER.
  294.  
  295.     ‚Ä¢SETTIME( number  ).Sets the column number where the survival times are
  296.      located  in the active data array. The Type is INTEGER.
  297.  
  298.     ‚Ä¢SETUNIT( 'days', 'weeks', 'months', 'years', 'user' ).Selects Time unit for
  299.     numerical and graphical output. You must put  one of the arguments in the list
  300.     above; otherwise you'll get an error message. The Type is STRING. 
  301.  
  302.   ‚Ä¢STAT(var,var, ...).Computes descriptive statistics (average, SD, SE, Min,Max
  303.     and Range) for the specified var. If you use an asterix sign as argument (*) the
  304.     statistics for all variables in the active data array are computed.
  305.  
  306.     ‚Ä¢TITLE ('My Title' ).Puts a custom title to the survival graph plot. The Type is
  307.     STRING.
  308.  
  309.   ‚Ä¢TPROB(T,df).Computes the exact  P value of Student T distribution T with
  310.     df degrees of freedom.
  311.  
  312.    ‚Ä¢TTEST(var1,var2,[Var3]);computes a Student T-Test betwen var1 and var2.
  313.    If you use the same value for var1 and var2 and use var3, which is optional,
  314.    a T-Test is computed for the groups in var3. The number of groups must be two
  315.    (use the RECODE or COMPUTE MACRO if necessary) otherwise you'll get an
  316.    error message.
  317.  
  318.     ‚Ä¢VARCODE (number, number..) identifyes type of variable for time-dependent 
  319.     analysis. number  is 1 for fixed covariates and 2 for time-dependent covariates.
  320.   The order should be the same than the selected variables of the model. 
  321.   Use this command only within a macro to activate Time-Dependent analysis.
  322.   You don't need to use this command in a macro if you employ only FIXED covariates.
  323.  
  324.     ‚Ä¢WRITE( arguments, arguments, ..)  writes the arguments to the active Output
  325.     Window. The arguments may be a string, a variable, a number, a formatting
  326.     string(eg. '#F6:2'), a Tabulator  ('tab') or Carriage Return ('cr');
  327.          Example:
  328.             TimeAverage:= 560; {you may compute this value}
  329.       Location:= 2
  330.             WRITE( 'The average survival time is','#F8:2',TimeAverage,' and is located in
  331.       Column', '#F2:0',location, 'cr');
  332.  
  333.   --------------------------------------------------------------------------
  334.  
  335. You may acces the numerical results of the Statistical Tests for further processing
  336. within a standard pascal procedure or macro with the TEMP[] Token as follows:
  337.  
  338. ================================================================
  339.                      Temp[1]     Temp[2]    Temp[3]   Temp[4]   Temp[5]   Temp[6]
  340.  
  341. -CHITEST       Chi-Value    P-value       df                
  342. -TTEST              T-Value       P-Value       df
  343. -CHIPROB       Chi-Value    P-Value       df       
  344. -NORMPROB    Z-Value      P-Value     
  345. -TPROB          T-Value      P-Value        df       
  346. -FPROB           F-Value      P-Value       df1          df2       
  347. -STAT(x)        Mean(x)    SD(x)        SE(x)        Min(x)    Max(x)    Range(x)
  348. -----------------------------------------------------------------------------
  349. Example
  350.  
  351.     if Temp[2] < 0.05 then RUNMACRO(2) else EXIT;
  352.  
  353.  
  354.     ‚Ä¢Standard Pascal Commands:
  355.  
  356.     -Procedure
  357.     -Begin...end
  358.     -For ...To...Do
  359.     -Repeat   Until
  360.     -While...Do
  361.     -If...Then...Else
  362.     -Var
  363.  
  364.     ‚Ä¢Operators:
  365.  
  366.     {, },+,   -,   *,   /,   DIV,  MOD,  :=,  =,  >=,  <=,  < >,  =
  367.  
  368.     ‚Ä¢Logical Operators:
  369.  
  370.     -AND
  371.     -OR
  372.     -NOT
  373.  
  374.     ‚Ä¢Pascal Types:
  375.  
  376.     -Integer; internally stored in extended precision
  377.     -Real; internally stored in extended precision
  378.     -Boolean: true,false
  379.  
  380.     ‚Ä¢Pascal Standard Functions
  381.  
  382.     -trunc(x)               converts real (x) to integer with truncation
  383.     -round(x)               converts x to integer with rounding
  384.     -random                 generates a random number between 0 and 1
  385.     -odd(x)                   returns true if integer x is odd
  386.     -abs(x)                   absolute value of x
  387.     -sqr(x);                  square of x
  388.     -sqrt(x)                  square root of x
  389.     -sin(x)                      sine of x
  390.     -cos(x)                    cosine of x
  391.     -arctan(x)               arctangent of x
  392.     -ln(x)                        natural logarithm of x
  393.     -exp(x)                    exponential of x
  394.  
  395.  
  396.  
  397. ‚Ä¢‚Ä¢ CUSTOM ARRAYS ‚Ä¢‚Ä¢ 
  398.  
  399.     Six different arrays are internally  defined for data manipulation;
  400.  
  401.     1) rVAR[k] ; vector of length MaxVars (30). Used to temporarily store the value
  402.   of the kth selected variable for a given test. You must use this token to access the
  403.   VAR values within  the COMPUTE ,FUNCTION, SELECTI, OMITIF, RECODE and
  404.   COUNTIF custom procedures.
  405.     2) rDATA [k] ; vector of length MaxVars (30). Used to temporarily store the
  406.    value of the kth  variable in the active data array. You must use this token to
  407.    access the VAR values within  the above mentioned custom procedures.
  408.     3) gVAR[offset]; the same as rVAR but it must be used within a macro or a
  409.   standard Pascal procedure.
  410.     4) gDATA[offset] ;the same as rDATA but it must be used within a macro or a
  411.   standard Pascal procedure. The Type of these arrays is REAL.
  412.  
  413.      As Total Data and Selected Data are stored in a one-column array of length
  414.    (rows * columns) to access the ith row of the kth column through the  gVAR and
  415.    gDATA tokens with a standardd Pascal procedure you must use the  routine listed
  416.    below. Notice that the structure of the routine follows the Pascal convention for a
  417.    standard procedure.
  418.  
  419.     macro 'My Macro'
  420.   var
  421.     rows,columns,nvars,index,i:integer;
  422.   myValue:real;
  423.     begin
  424.     GET(rows,columns,nvars); {get number of rows, columns and selected vars}
  425.     for i:= 0 to rows -1 do
  426.       begin
  427.          index:= i * columns + 3;{access the value in column 3 of the ith row}
  428.                    myValue:= gDATA[index];
  429.           etc;
  430.             end;
  431.     end;
  432.                    
  433.     5) rMEAN [k]; vector of REAL Type and MaxVars(30) length which stores the
  434.   vector of average values for the kth selected variable of the ith individual.
  435.   Currently used with the Time Dependent option.
  436.     6) TEMP [k]; Vector of REAL Type and MaxVars(30) length which stores the code
  437.   of the kth selected variable for the model of the ith individual or case. This value
  438.   is = 1 for Fixed Covariates and = 2 for Time Dependent Covariates. You may use
  439.   TEMP[k] for the temporary storage of any value or variable within a standard
  440.   Pascal procedure.
  441.  
  442.         
  443.  
  444.  
  445.  
  446.  
  447.  
  448.  
  449.